//package cn.myschool.web;
//
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.Date;
//
///**
// * @author oldliu
// * @since 1.0
// */
//@Component("timeHandler")
//public class TimeHandler implements HandlerInterceptor {
//
//    @Override//返回false,请求停止
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
//        System.out.println(handler+" 是控制器："+new Date()+",请求地址是"+request.getServletPath());
//
//        Object o=request.getSession().getAttribute("loginuser");
//       if(o==null){
//           try {
//               request.setAttribute("msg","您还没有登录");
//               request.getRequestDispatcher("/login.jsp").forward(request,response);
//           } catch (ServletException e) {
//               e.printStackTrace();
//           } catch (IOException e) {
//               e.printStackTrace();
//           }
//           return  false;
//       }
//        return true;
//    }
//
//    @Override
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
//        System.out.println(handler+"执行结束，结果是"+modelAndView);
//    }
//
//    @Override
//    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
//        System.out.println(handler+"视图解析结束！");
//    }
//}
